var footImg = ["../../img/home_cn/home-box-1_CN.jpg", "../../img/home_cn/home-box-2_CN.jpg", "../../img/home_cn/home-box-3_CN.jpg"]; //存放底部左边的三张图片路径
var footHImg = ["../../img/home_cn/home-box-1_CN_hover.jpg", "../../img/home_cn/home-box-2_CN_hover.jpg", "../../img/home_cn/home-box-3_CN_hover.jpg"]; //存放底部左边的三张hover图片路径
var rightArr = ["../../img/home_cn/weibo_CN.jpg", "../../img/home_cn/weixin_CN.jpg"]; //存放底部右边的两张图片路径
var rightHArr = ["../../img/home_cn/weibo_CN_hover.jpg", "../../img/home_cn/weixin_CN_hover.jpg"]; //存放底部右边的两张hover图片路径
//存放右边动画效果图的路径
var picArr = ["../../img/home_cn/pic1.jpg", "../../img/home_cn/pic2.jpg", "../../img/home_cn/pic3.jpg"];
var tgbArr = ["../../img/home_cn/tbg1.png", "../../img/home_cn/tbg2.png", "../../img/home_cn/tbg3.png"];
var TArr = ["../../img/home_cn/t1.png", "../../img/home_cn/t2.png", "../../img/home_cn/t3.png"];
var WArr = ["../../img/home_cn/w1.png", "../../img/home_cn/w2.png", "../../img/home_cn/w3.png"];
//国际化
function setLanguage(obj) {
	$("#topChina").html(obj.topCountry);
	$("#language a").html(obj.topA);
	$("header>nav>a>li>span").eq(0).html(obj.news);
	$("header>nav>a>li>span").eq(1).html(obj.menu);
	$("header>nav>a>li>span").eq(2).html(obj.develop);
	$("header>nav>a>li>span").eq(3).html(obj.about);
	$("header>nav>a>li>span").eq(4).html(obj.local);
	$("#slideNav>li>a").eq(0).html(obj.value);
	$("#slideNav>li>a").eq(1).html(obj.classics);
	$("#slideNav>li>a").eq(2).html(obj.premium);
	$("#slideNav>li>a").eq(3).html(obj.lowFat);
	$("#slideNav>li>a").eq(4).html(obj.wrap);
	$("#slideNav>li>a").eq(5).html(obj.salad);
	$("#slideNav>li>a").eq(6).html(obj.catering);
	$("#slideNav>li>a").eq(7).html(obj.drinksAndSides);
	$("#slideNav>li>a").eq(8).html(obj.breakfast);
	$("#slideNav>li>a").eq(9).html(obj.nutrition);
	$("#slideNav>li>a").eq(10).html(obj.howToOrder);
	$("#animatePicContainer>img").eq(1).prop("src", obj.TArr[0]);
	$("#animatePicContainer>img").eq(2).prop("src", obj.WArr[0]);
	TArr = obj.TArr;
	WArr = obj.WArr;
	$("#footerLeft>img").eq(0).prop("src", obj.footLeftImg[0]);
	$("#footerLeft>img").eq(1).prop("src", obj.footLeftImg[1]);
	$("#footerLeft>img").eq(2).prop("src", obj.footLeftImg[2]);
	$("#footerRight>img").eq(0).prop("src", obj.rightArr[0]);
	$("#footerRight>img").eq(1).prop("src", obj.rightArr[1]);
	footImg = obj.footLeftImg;
	footHImg = obj.footLeftHImg;
	rightArr = obj.rightArr;
	rightHArr = obj.rightHArr;
	$(".footerMenuA").each(function(ind) {
		$(".footerMenuA").eq(ind).html(obj.hArr[ind]);
	});
}
//设置语言
$("select ").change(function() {
	if($("select :nth-child(2)").prop("selected") == true) {
		setLanguage(enObj);
		footImgHover("#footerLeft :first-child", footHImg[0], footImg[0]);
		footImgHover("#footerLeft :nth-child(2)", footHImg[1], footImg[1]);
		footImgHover("#footerLeft :last-child", footHImg[2], footImg[2]);
		footImgHover("#footerRight :first-child", rightHArr[0], rightArr[0]);
		footImgHover("#footerRight :last-child", rightHArr[1], rightArr[1]);
	} else if($("select :nth-child(3)").prop("selected") == true) {
		setLanguage(cnObj);
		footImgHover("#footerLeft :first-child", footHImg[0], footImg[0]);
		footImgHover("#footerLeft :nth-child(2)", footHImg[1], footImg[1]);
		footImgHover("#footerLeft :last-child", footHImg[2], footImg[2]);
		footImgHover("#footerRight :first-child", rightHArr[0], rightArr[0]);
		footImgHover("#footerRight :last-child", rightHArr[1], rightArr[1]);
	}
});
//轮播图点击按钮hover效果
$("#CarouselImg").hover(function() {
	$("#CarouselImg>div").css("display", "block");
}, function() {
	$("#CarouselImg>div").css("display", "none");
});
//轮播图自动轮播事件
setInterval(function() {
	if($("#CarouselImg1").css("opacity") == 1) {
		$("#CarouselImg1").animate({ opacity: 0 }, 1000)
		$("#CarouselImg2").animate({ opacity: 1 }, 1000)
	} else {
		$("#CarouselImg1").animate({ opacity: 1 }, 1000)
		$("#CarouselImg2").animate({ opacity: 0 }, 1000)
	}
}, 6000);
//点击轮播图效果
$("#CarouselImg>img").on("click", function() {
	if($("#CarouselImg1").css("opacity") != 0) {
		window.open("http://www.subway.com.cn/images/uploadImg/2016040117224114977a.png");
	} else if($("#CarouselImg2").css("opacity") != 0) {
		window.open("http://www.subway.com.cn/images/uploadImg/201612191444322d3b38.jpg");
	}

});
//点击轮播图按钮事件
$("#CarouselImg>div").on("click", function() {
	if($("#CarouselImg1").css("opacity") == 1) {
		$("#CarouselImg1").animate({ opacity: 0 }, 500)
		$("#CarouselImg2").animate({ opacity: 1 }, 500)
	} else {
		$("#CarouselImg1").animate({ opacity: 1 }, 500)
		$("#CarouselImg2").animate({ opacity: 0 }, 500)
	}
});
//封装图片hover效果
function footImgHover(obj, path1, path2) {
	$(obj).hover(function() {
		$(obj).prop("src", path1);
	}, function() {
		$(obj).prop("src", path2);
	});
}
footImgHover("#footerLeft :first-child", footHImg[0], footImg[0]);
footImgHover("#footerLeft :nth-child(2)", footHImg[1], footImg[1]);
footImgHover("#footerLeft :last-child", footHImg[2], footImg[2]);
footImgHover("#footerRight :first-child", rightHArr[0], rightArr[0]);
footImgHover("#footerRight :last-child", rightHArr[1], rightArr[1]);
$("#footerRight :last-child").hover(function() { //给微信加hover出二维码的效果
	$("#QRcode").css("display", "block");
}, function() {
	$("#QRcode").css("display", "none");
});

//右边动图效果
setInterval(function() { //计时器做进来动画
	$("#animateTGB").animate({ top: 0 }, 500, function() {
		$("#animateT").animate({ left: 0 }, 500, function() {
			$("#animateW").animate({ left: 0 }, 500, function() {
				setTimeout(function() {
					animateOut();
				}, 2000);
			})
		})
	})
}, 6000);
var i = 1;
function animateOut() { //出去的动画
	$("#animateT").animate({ left: "300px" }, 500, function() {
		$("#animateW").animate({ left: "300px" }, 500, function() {
			$("#animateTGB").animate({ top: "-160px" }, 500, function() {
				$("#animateT").css("left", "-300px");
				$("#animateW").css("left", "-300px");
				$("#animatePic").animate({ opacity: 0 }, 500, function() { //出完之后重置,并改变图片路径
					$("#animatePicContainer :last-child").prop("src", picArr[i]);
					$("#animatePicContainer :first-child").prop("src", tgbArr[i]);
					$("#animatePicContainer :nth-child(2)").prop("src", TArr[i]);
					$("#animatePicContainer :nth-child(3)").prop("src", WArr[i]);
					$("#animatePic").animate({ opacity: 1 }, 500);
					i++;
					if(i == picArr.length) {
						i = 0;
					}
				});
			})
		})
	})
};
//下拉菜单栏
$("#liSlide").hover(function() {
	$("#slideNav").css("display", "block");
}, function() {
	$("#slideNav").css("display", "none");
})
$("#slideNav").on("mouseleave", function() {
	$("#slideNav").css("display", "none");
})
$("#slideNav").on("mouseenter", function() {
	$("#slideNav").css("display", "block");
})
//下拉菜单栏的hover
$("#slideNav>li").hover(function() {
	$(this).children("a").css("color", "yellow");
}, function() {
	$(this).children("a").css("color", "white");
})
//点击下面三张图的事件
$("#footerLeft>img").eq(0).on("click",function(){
	window.location.href = "position.html";
})
$("#footerLeft>img").eq(1).on("click",function(){
	window.location.href = "howtoorder.html";
})
$("#footerLeft>img").eq(2).on("click",function(){
	window.location.href = "sales.html";
})
